﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="ETTeavitusParing", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(ETTeavitusParing))]
    public class ETTeavitusParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IETTeavitusParing clazz;
        
        public ETTeavitusParingSerializer(IETTeavitusParing clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Teavitus!=null) {
                Writer.WriteStartElement("teavitus");
                global::Xtee.Core.SerializationMetadata metaTeavitus = this.GetMetaData(clazz.Teavitus);
                Writer.WriteTypeAttribute(metaTeavitus.TypeQualifiedName.Namespace, metaTeavitus.TypeQualifiedName.Name);
                metaTeavitus.NewSerializer(clazz.Teavitus).WriteXml(Writer);
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "teavitus")) {
                goto teavitus;
            }
            else {
                return;
            }
        teavitus:
            if ((Reader.IsElementNil() == false)) {
                global::Xtee.Core.SerializationMetadata metaTeavitus = this.GetMetaData<global::Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik.IStandardTeavitus>(Reader, "StandardTeavitus", "http://producers.etoimik.xtee.riik.ee/producer/etoimik");
                clazz.Teavitus = metaTeavitus.NewEntity<global::Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik.IStandardTeavitus>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("teavitus");
                    metaTeavitus.NewSerializer(clazz.Teavitus).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                Reader.Skip();
            }
            goto START;
        }
    }
}
